{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8f4d19e4-df7f-4857-b59c-7791e62c1da4",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.model_selection import cross_val_predict\n",
    "from sklearn.metrics import roc_auc_score\n",
    "from lightgbm import LGBMClassifier"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "cee977f3-8bbf-4706-9b13-881a18b77dba",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "train_data = pd.read_csv('./汽车保险索赔预测挑战赛公开数据/train.csv')\n",
    "test_data = pd.read_csv('./汽车保险索赔预测挑战赛公开数据/test.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "6f3de590-20f9-49b7-ba85-5c52f4e96817",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>policy_tenure</th>\n",
       "      <th>age_of_car</th>\n",
       "      <th>age_of_policyholder</th>\n",
       "      <th>area_cluster</th>\n",
       "      <th>population_density</th>\n",
       "      <th>make</th>\n",
       "      <th>segment</th>\n",
       "      <th>model</th>\n",
       "      <th>fuel_type</th>\n",
       "      <th>...</th>\n",
       "      <th>is_brake_assist</th>\n",
       "      <th>is_power_door_locks</th>\n",
       "      <th>is_central_locking</th>\n",
       "      <th>is_power_steering</th>\n",
       "      <th>is_driver_seat_height_adjustable</th>\n",
       "      <th>is_day_night_rear_view_mirror</th>\n",
       "      <th>is_ecw</th>\n",
       "      <th>is_speed_alert</th>\n",
       "      <th>ncap_rating</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0.036295</td>\n",
       "      <td>0.021216</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>4076</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.145070</td>\n",
       "      <td>0.023511</td>\n",
       "      <td>8</td>\n",
       "      <td>7</td>\n",
       "      <td>8794</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.206939</td>\n",
       "      <td>0.042872</td>\n",
       "      <td>43</td>\n",
       "      <td>7</td>\n",
       "      <td>8794</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>1.106526</td>\n",
       "      <td>0.116451</td>\n",
       "      <td>33</td>\n",
       "      <td>14</td>\n",
       "      <td>290</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>0.033766</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>21</td>\n",
       "      <td>4</td>\n",
       "      <td>34738</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 44 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  policy_tenure  age_of_car  age_of_policyholder  area_cluster  \\\n",
       "0   0       0.036295    0.021216                   11             2   \n",
       "1   1       0.145070    0.023511                    8             7   \n",
       "2   2       1.206939    0.042872                   43             7   \n",
       "3   3       1.106526    0.116451                   33            14   \n",
       "4   4       0.033766    0.000000                   21             4   \n",
       "\n",
       "   population_density  make  segment  model  fuel_type  ...  is_brake_assist  \\\n",
       "0                4076     1        0      0          0  ...                0   \n",
       "1                8794     1        0      0          0  ...                0   \n",
       "2                8794     3        2      3          2  ...                1   \n",
       "3                 290     3        2      3          2  ...                1   \n",
       "4               34738     1        0      0          0  ...                0   \n",
       "\n",
       "   is_power_door_locks  is_central_locking  is_power_steering  \\\n",
       "0                    0                   0                  0   \n",
       "1                    0                   0                  0   \n",
       "2                    1                   1                  0   \n",
       "3                    1                   1                  0   \n",
       "4                    0                   0                  0   \n",
       "\n",
       "   is_driver_seat_height_adjustable  is_day_night_rear_view_mirror  is_ecw  \\\n",
       "0                                 0                              0       0   \n",
       "1                                 0                              0       0   \n",
       "2                                 1                              0       1   \n",
       "3                                 1                              0       1   \n",
       "4                                 0                              0       0   \n",
       "\n",
       "   is_speed_alert  ncap_rating  target  \n",
       "0               0            0       0  \n",
       "1               0            0       0  \n",
       "2               0            3       0  \n",
       "3               0            3       0  \n",
       "4               0            0       0  \n",
       "\n",
       "[5 rows x 44 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "898c305c-1e87-4427-a759-b64ea38788e9",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "id                                    int64\n",
       "policy_tenure                       float64\n",
       "age_of_car                          float64\n",
       "age_of_policyholder                   int64\n",
       "area_cluster                          int64\n",
       "population_density                    int64\n",
       "make                                  int64\n",
       "segment                               int64\n",
       "model                                 int64\n",
       "fuel_type                             int64\n",
       "max_torque                            int64\n",
       "max_power                             int64\n",
       "engine_type                           int64\n",
       "airbags                               int64\n",
       "is_esc                                int64\n",
       "is_adjustable_steering                int64\n",
       "is_tpms                               int64\n",
       "is_parking_sensors                    int64\n",
       "is_parking_camera                     int64\n",
       "rear_brakes_type                      int64\n",
       "displacement                          int64\n",
       "cylinder                              int64\n",
       "transmission_type                     int64\n",
       "gear_box                              int64\n",
       "steering_type                         int64\n",
       "turning_radius                      float64\n",
       "length                                int64\n",
       "width                                 int64\n",
       "height                                int64\n",
       "gross_weight                          int64\n",
       "is_front_fog_lights                   int64\n",
       "is_rear_window_wiper                  int64\n",
       "is_rear_window_washer                 int64\n",
       "is_rear_window_defogger               int64\n",
       "is_brake_assist                       int64\n",
       "is_power_door_locks                   int64\n",
       "is_central_locking                    int64\n",
       "is_power_steering                     int64\n",
       "is_driver_seat_height_adjustable      int64\n",
       "is_day_night_rear_view_mirror         int64\n",
       "is_ecw                                int64\n",
       "is_speed_alert                        int64\n",
       "ncap_rating                           int64\n",
       "target                                int64\n",
       "dtype: object"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.dtypes"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "24354092-c69c-49c9-945f-7aca6fe40c0d",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "id                                  0.0\n",
       "policy_tenure                       0.0\n",
       "age_of_car                          0.0\n",
       "age_of_policyholder                 0.0\n",
       "area_cluster                        0.0\n",
       "population_density                  0.0\n",
       "make                                0.0\n",
       "segment                             0.0\n",
       "model                               0.0\n",
       "fuel_type                           0.0\n",
       "max_torque                          0.0\n",
       "max_power                           0.0\n",
       "engine_type                         0.0\n",
       "airbags                             0.0\n",
       "is_esc                              0.0\n",
       "is_adjustable_steering              0.0\n",
       "is_tpms                             0.0\n",
       "is_parking_sensors                  0.0\n",
       "is_parking_camera                   0.0\n",
       "rear_brakes_type                    0.0\n",
       "displacement                        0.0\n",
       "cylinder                            0.0\n",
       "transmission_type                   0.0\n",
       "gear_box                            0.0\n",
       "steering_type                       0.0\n",
       "turning_radius                      0.0\n",
       "length                              0.0\n",
       "width                               0.0\n",
       "height                              0.0\n",
       "gross_weight                        0.0\n",
       "is_front_fog_lights                 0.0\n",
       "is_rear_window_wiper                0.0\n",
       "is_rear_window_washer               0.0\n",
       "is_rear_window_defogger             0.0\n",
       "is_brake_assist                     0.0\n",
       "is_power_door_locks                 0.0\n",
       "is_central_locking                  0.0\n",
       "is_power_steering                   0.0\n",
       "is_driver_seat_height_adjustable    0.0\n",
       "is_day_night_rear_view_mirror       0.0\n",
       "is_ecw                              0.0\n",
       "is_speed_alert                      0.0\n",
       "ncap_rating                         0.0\n",
       "target                              0.0\n",
       "dtype: float64"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.isnull().mean(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "f2179eb3-70cf-43e5-a6b6-7a025a15f162",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7786970216745239"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val_pred = cross_val_predict(\n",
    "    LGBMClassifier(verbose=0, force_row_wise=True),\n",
    "    train_data.drop(['id', 'target'], axis=1),\n",
    "    train_data['target'],\n",
    "    method='predict_proba'\n",
    ")\n",
    "roc_auc_score(train_data['target'], val_pred[:, 1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "ca6d8ba3-ed9a-467e-8902-35100fe4d679",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>id</th>\n",
       "      <th>policy_tenure</th>\n",
       "      <th>age_of_car</th>\n",
       "      <th>age_of_policyholder</th>\n",
       "      <th>area_cluster</th>\n",
       "      <th>population_density</th>\n",
       "      <th>make</th>\n",
       "      <th>segment</th>\n",
       "      <th>model</th>\n",
       "      <th>fuel_type</th>\n",
       "      <th>...</th>\n",
       "      <th>is_brake_assist</th>\n",
       "      <th>is_power_door_locks</th>\n",
       "      <th>is_central_locking</th>\n",
       "      <th>is_power_steering</th>\n",
       "      <th>is_driver_seat_height_adjustable</th>\n",
       "      <th>is_day_night_rear_view_mirror</th>\n",
       "      <th>is_ecw</th>\n",
       "      <th>is_speed_alert</th>\n",
       "      <th>ncap_rating</th>\n",
       "      <th>target</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0</td>\n",
       "      <td>0.036295</td>\n",
       "      <td>0.021216</td>\n",
       "      <td>11</td>\n",
       "      <td>2</td>\n",
       "      <td>4076</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>0.145070</td>\n",
       "      <td>0.023511</td>\n",
       "      <td>8</td>\n",
       "      <td>7</td>\n",
       "      <td>8794</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2</td>\n",
       "      <td>1.206939</td>\n",
       "      <td>0.042872</td>\n",
       "      <td>43</td>\n",
       "      <td>7</td>\n",
       "      <td>8794</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>3</td>\n",
       "      <td>1.106526</td>\n",
       "      <td>0.116451</td>\n",
       "      <td>33</td>\n",
       "      <td>14</td>\n",
       "      <td>290</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>3</td>\n",
       "      <td>2</td>\n",
       "      <td>...</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>4</td>\n",
       "      <td>0.033766</td>\n",
       "      <td>0.000000</td>\n",
       "      <td>21</td>\n",
       "      <td>4</td>\n",
       "      <td>34738</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>...</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>5 rows × 44 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "   id  policy_tenure  age_of_car  age_of_policyholder  area_cluster  \\\n",
       "0   0       0.036295    0.021216                   11             2   \n",
       "1   1       0.145070    0.023511                    8             7   \n",
       "2   2       1.206939    0.042872                   43             7   \n",
       "3   3       1.106526    0.116451                   33            14   \n",
       "4   4       0.033766    0.000000                   21             4   \n",
       "\n",
       "   population_density  make  segment  model  fuel_type  ...  is_brake_assist  \\\n",
       "0                4076     1        0      0          0  ...                0   \n",
       "1                8794     1        0      0          0  ...                0   \n",
       "2                8794     3        2      3          2  ...                1   \n",
       "3                 290     3        2      3          2  ...                1   \n",
       "4               34738     1        0      0          0  ...                0   \n",
       "\n",
       "   is_power_door_locks  is_central_locking  is_power_steering  \\\n",
       "0                    0                   0                  0   \n",
       "1                    0                   0                  0   \n",
       "2                    1                   1                  0   \n",
       "3                    1                   1                  0   \n",
       "4                    0                   0                  0   \n",
       "\n",
       "   is_driver_seat_height_adjustable  is_day_night_rear_view_mirror  is_ecw  \\\n",
       "0                                 0                              0       0   \n",
       "1                                 0                              0       0   \n",
       "2                                 1                              0       1   \n",
       "3                                 1                              0       1   \n",
       "4                                 0                              0       0   \n",
       "\n",
       "   is_speed_alert  ncap_rating  target  \n",
       "0               0            0       0  \n",
       "1               0            0       0  \n",
       "2               0            3       0  \n",
       "3               0            3       0  \n",
       "4               0            0       0  \n",
       "\n",
       "[5 rows x 44 columns]"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "train_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "c82b1130-56ad-4455-a2a7-d76fbd967ead",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "train_data['age_of_policyholder_minus_car'] = train_data['age_of_policyholder'] - train_data['age_of_car']\n",
    "train_data['length_div_width'] = train_data['length'] / train_data['width']\n",
    "train_data['max_torque_div_power'] = train_data['max_torque'] / train_data['max_power']\n",
    "\n",
    "test_data['age_of_policyholder_minus_car'] = test_data['age_of_policyholder'] - test_data['age_of_car']\n",
    "test_data['length_div_width'] = test_data['length'] / test_data['width']\n",
    "test_data['max_torque_div_power'] = test_data['max_torque'] / test_data['max_power']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "6440b6dc-3792-480b-9644-63b8f6c1fafd",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.7805077165344044"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val_pred = cross_val_predict(\n",
    "    LGBMClassifier(verbose=0, force_row_wise=True),\n",
    "    train_data.drop(['id', 'target'], axis=1),\n",
    "    train_data['target'],\n",
    "    method='predict_proba'\n",
    ")\n",
    "roc_auc_score(train_data['target'], val_pred[:, 1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "db9bea3f-13e5-4d16-b593-07a0ed5c9973",
   "metadata": {
    "tags": []
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<style>#sk-container-id-1 {color: black;background-color: white;}#sk-container-id-1 pre{padding: 0;}#sk-container-id-1 div.sk-toggleable {background-color: white;}#sk-container-id-1 label.sk-toggleable__label {cursor: pointer;display: block;width: 100%;margin-bottom: 0;padding: 0.3em;box-sizing: border-box;text-align: center;}#sk-container-id-1 label.sk-toggleable__label-arrow:before {content: \"▸\";float: left;margin-right: 0.25em;color: #696969;}#sk-container-id-1 label.sk-toggleable__label-arrow:hover:before {color: black;}#sk-container-id-1 div.sk-estimator:hover label.sk-toggleable__label-arrow:before {color: black;}#sk-container-id-1 div.sk-toggleable__content {max-height: 0;max-width: 0;overflow: hidden;text-align: left;background-color: #f0f8ff;}#sk-container-id-1 div.sk-toggleable__content pre {margin: 0.2em;color: black;border-radius: 0.25em;background-color: #f0f8ff;}#sk-container-id-1 input.sk-toggleable__control:checked~div.sk-toggleable__content {max-height: 200px;max-width: 100%;overflow: auto;}#sk-container-id-1 input.sk-toggleable__control:checked~label.sk-toggleable__label-arrow:before {content: \"▾\";}#sk-container-id-1 div.sk-estimator input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-label input.sk-toggleable__control:checked~label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 input.sk-hidden--visually {border: 0;clip: rect(1px 1px 1px 1px);clip: rect(1px, 1px, 1px, 1px);height: 1px;margin: -1px;overflow: hidden;padding: 0;position: absolute;width: 1px;}#sk-container-id-1 div.sk-estimator {font-family: monospace;background-color: #f0f8ff;border: 1px dotted black;border-radius: 0.25em;box-sizing: border-box;margin-bottom: 0.5em;}#sk-container-id-1 div.sk-estimator:hover {background-color: #d4ebff;}#sk-container-id-1 div.sk-parallel-item::after {content: \"\";width: 100%;border-bottom: 1px solid gray;flex-grow: 1;}#sk-container-id-1 div.sk-label:hover label.sk-toggleable__label {background-color: #d4ebff;}#sk-container-id-1 div.sk-serial::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: 0;}#sk-container-id-1 div.sk-serial {display: flex;flex-direction: column;align-items: center;background-color: white;padding-right: 0.2em;padding-left: 0.2em;position: relative;}#sk-container-id-1 div.sk-item {position: relative;z-index: 1;}#sk-container-id-1 div.sk-parallel {display: flex;align-items: stretch;justify-content: center;background-color: white;position: relative;}#sk-container-id-1 div.sk-item::before, #sk-container-id-1 div.sk-parallel-item::before {content: \"\";position: absolute;border-left: 1px solid gray;box-sizing: border-box;top: 0;bottom: 0;left: 50%;z-index: -1;}#sk-container-id-1 div.sk-parallel-item {display: flex;flex-direction: column;z-index: 1;position: relative;background-color: white;}#sk-container-id-1 div.sk-parallel-item:first-child::after {align-self: flex-end;width: 50%;}#sk-container-id-1 div.sk-parallel-item:last-child::after {align-self: flex-start;width: 50%;}#sk-container-id-1 div.sk-parallel-item:only-child::after {width: 0;}#sk-container-id-1 div.sk-dashed-wrapped {border: 1px dashed gray;margin: 0 0.4em 0.5em 0.4em;box-sizing: border-box;padding-bottom: 0.4em;background-color: white;}#sk-container-id-1 div.sk-label label {font-family: monospace;font-weight: bold;display: inline-block;line-height: 1.2em;}#sk-container-id-1 div.sk-label-container {text-align: center;}#sk-container-id-1 div.sk-container {/* jupyter's `normalize.less` sets `[hidden] { display: none; }` but bootstrap.min.css set `[hidden] { display: none !important; }` so we also need the `!important` here to be able to override the default hidden behavior on the sphinx rendered scikit-learn.org. See: https://github.com/scikit-learn/scikit-learn/issues/21755 */display: inline-block !important;position: relative;}#sk-container-id-1 div.sk-text-repr-fallback {display: none;}</style><div id=\"sk-container-id-1\" class=\"sk-top-container\"><div class=\"sk-text-repr-fallback\"><pre>LGBMClassifier(force_row_wise=True, verbose=0)</pre><b>In a Jupyter environment, please rerun this cell to show the HTML representation or trust the notebook. <br />On GitHub, the HTML representation is unable to render, please try loading this page with nbviewer.org.</b></div><div class=\"sk-container\" hidden><div class=\"sk-item\"><div class=\"sk-estimator sk-toggleable\"><input class=\"sk-toggleable__control sk-hidden--visually\" id=\"sk-estimator-id-1\" type=\"checkbox\" checked><label for=\"sk-estimator-id-1\" class=\"sk-toggleable__label sk-toggleable__label-arrow\">LGBMClassifier</label><div class=\"sk-toggleable__content\"><pre>LGBMClassifier(force_row_wise=True, verbose=0)</pre></div></div></div></div></div>"
      ],
      "text/plain": [
       "LGBMClassifier(force_row_wise=True, verbose=0)"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "m = LGBMClassifier(verbose=0, force_row_wise=True)\n",
    "m.fit(\n",
    "    train_data.drop(['id', 'target'], axis=1),\n",
    "    train_data['target'],\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "bf591a96-4da8-4f0e-84c7-7946d23593b1",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "test_data['target'] = m.predict_proba(test_data.drop(['id'], axis=1))[:, 1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "423a3359-bba9-4ce9-b602-d1aaa86be82b",
   "metadata": {
    "tags": []
   },
   "outputs": [],
   "source": [
    "test_data[['id', 'target']].to_csv('submit2.csv', index=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7f206249-d59a-4622-ba91-c56f85e3a8b8",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3.10"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.10"
  },
  "widgets": {
   "application/vnd.jupyter.widget-state+json": {
    "state": {},
    "version_major": 2,
    "version_minor": 0
   }
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
